package com.gitee.wsl.security.encrypt.sample

import com.gitee.wsl.security.encrypt.Encrypt
import com.gitee.wsl.security.encrypt.StringToStringEncrypt

/**
 * @author Leon
 * @since 2023-04-23 11:50
 * @email deadogone@gmail.com
 */

object HackWord :StringToStringEncrypt{
    private val HACKER_DICT =
        mapOf(
            "A" to "4",
            "E" to "3",
            "I" to "1",
            "O" to "0",
            "S" to "5",
            "T" to "7",
        )

    private val HACKER_DICT_REVERSE = HACKER_DICT.values.zip(HACKER_DICT.keys).toMap()

    override fun decrypt(src: String): String =
        src.uppercase().map { HACKER_DICT_REVERSE[it.toString()] ?: it }.joinToString("").lowercase()

    override fun encrypt(src: String): String =
        src.uppercase().map { HACKER_DICT[it.toString()] ?: it }.joinToString("")

}

val Encrypt.Companion.hackWord get() =HackWord

